const ora = require('ora');
// 封装loading外壳
const wrapLoading = async (fn, message, ...args) => {
  const spinner = ora(message);
  spinner.start();
  try {
    const result = await fn(...args);
    spinner.succeed();
    // console.log('----result', result);
    return result;
  } catch (error) {
    spinner.fail('Request failed, please refetch...');
    throw new Error(error);
  }
};
module.exports = {
  wrapLoading
};
